--- %%NOBANNER%% -->
/*-------------------<-- Start of Description -->--------------------\
| Remove all the formats and informats from a data set; |
|---------------------<-- End of Description -->---------------------|
|--------------------------------------------------------------------|
|-----------<-- Start of Files or Arguements Needed-->---------------|
| Arguments: |
| indata - input data set you want to remove the formats and |
| informats; |
| outdata - the output data you want to created from the indata; |
|------------<-- End of Files or Arguements Needed-->----------------|
|--------------------------------------------------------------------|
|------------------<-- Start of Files Created-->---------------------|
| Example: %delfmt(indata=work.citstate, outdata=citstate); |
| Usage: %delfmt(indata,outdata); |
\------------------<-- Start of Files Created-->--------------------*/
%macro delfmt/parmbuff des = "Remove all formats from dataset";
/*--------------------------------------------\
| Author: Duo Zhou; |
| Created: 2-1-2002 8:23pm; |
| Purpose: Remove all the formats and informat|
| from a dataset; |
\--------------------------------------------*/
%local libref;
%let inbuff=%qscan(&syspbuff,1,%str((),));
%let outbuff=%qscan(&syspbuff,2,%str((),));
%let linesize = %SYSFUNC(GETOPTION(linesize));
%if (%index(%quote(&syspbuff),%quote(=))) %then %do;
%if (%index(%quote(&inbuff),%quote(=))) %then %do;
%if (%index(%quote(%upcase(%sysfunc(compress(%quote(&inbuff))))),%quote(INDATA=))) %then %do;
%let indata=%qscan(&inbuff,2,%str(=));
%if (%index(%quote(&outbuff),%quote(=))) %then %do;
%if (not %index(%quote(%upcase(%sysfunc(compress(%quote(&outbuff))))),%quote(OUTDATA=))) %then
%put ==> Alert! Keyword parameter "%qscan(&outbuff,1,%str(=))" is not defined!;
%else %let outdata=%qscan(&outbuff,2,%str(=));
%end;
%else %let outdata=&outbuff;
%end;
%else %if (%index(%quote(%upcase(%sysfunc(compress(%quote(&inbuff))))),%quote(OUTDATA=))) %then %do;
%let outdata=%qscan(&inbuff,2,%str(=));
%if (%index(%quote(&outbuff),%quote(=))) %then %do;
%if (not %index(%quote(%upcase(%sysfunc(compress(%quote(&outbuff))))),%quote(INDATA=))) %then
%put ==> Alert! Keyword parameter "%qscan(&outbuff,1,%str(=))" is not defined!;
%else %let indata=%qscan(&outbuff,2,%str(=));
%end;
%else %let indata=&outbuff;
%end;
%else %put ==> Alert! Keyword parameter "%qscan(&inbuff,1,%str(=))" is not defined!;
%end;
%else %if (%index(%quote(&outbuff),%quote(=))) %then %do;
%if (%index(%quote(%upcase(%sysfunc(compress(%quote(&outbuff))))),%quote(INDATA=))) %then %do;
%let indata=%qscan(&outbuff,2,%str(=)); %let outdata=&inbuff;
%end;
%else %if (%index(%quote(%upcase(%sysfunc(compress(%quote(&outbuff))))),%quote(OUTDATA=))) %then %do;
%let indata=&inbuff;
%let outdata=%qscan(&outbuff,2,%str(=));
%end;
%else %put ==> Alert! Keyword parameter "%qscan(&outbuff,1,%str(=))" is not defined!;
%end;
%end;
%else %do; %let indata=&inbuff; %let outdata=&outbuff; %end;
%if (%quote(&indata)= ) %then %let indata=&syslast;
%if (%quote(&outdata)= ) %then %let outdata=&indata;
%if (%quote(&indata) ne) %then %do;
%if %sysfunc(exist(&indata)) %then %do;
%if (%index(%quote(&indata), %quote(.))) %then %do;
%let inbref=%qscan(&indata, 1, %str(.));
%let indata=%qscan(&indata, 2, %str(.));
%end;
%else %let inbref=work;
%if (&outdata ne) and (%index(%quote(&outdata), %quote(.))) %then %do;
%let outbref=%qscan(&outdata, 1, %str(.));
%let outdata=%qscan(&outdata, 2, %str(.));
%end;
%else %let outbref=work;
%if (&inbref eq) %then %let inbref=work;
%let inbref=%upcase(&inbref); %let indata=%upcase(&indata);
%if (&outbref eq) %then %let outbref=work;
%let outbref=%upcase(&outbref); %let outdata=%upcase(&outdata); %let uname =;
options NOFMTERR;
proc sql ;
select name, format, informat into
:uname separated by ' ', /* variable names */
:ufmt separated by ' ', /* format to remove not used */
:unfmt separated by ' ' /* informat to remove not used */
from sashelp.vcolumn
where upcase(libname) eq "%trim(%left(%upcase(&inbref)))" and
upcase(memname) eq "%trim(%left(%upcase(&indata)))" and
memtype eq "DATA" and format ne "";
quit;
data %trim(%left(&outbref)).%trim(%left(&outdata));
set %trim(%left(&inbref)).%trim(%left(&indata));
run;
%if (%quote(&uname) ne) %then %do;
proc datasets nolist library=&outbref memtype=data;
modify &outdata; format &uname; informat &uname;
quit;
%end;
%else %put --> Note: Input data set doesn%str(%')t have any format to remove!;
run;
%end;
%else %put ==> Alert! Data set "&indata" does not exist!;
%end;
%else %put ==> Alert! An input data set is needed!;
%mend delfmt;